package com.ocom.srvpaccess.controller;

import com.ocom.common.constant.SrvpAccessDeviceUrl;
import com.ocom.common.dto.PerInfoDto;
import com.ocom.common.enums.MachEnum;
import com.ocom.common.resp.RespMachMessage;
import com.ocom.common.utils.RespUtilMach;
import com.ocom.srvpaccess.service.PersonnelInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersonController {

	@Autowired
	PersonnelInfoService personnelInfoService;

	@PostMapping(value = SrvpAccessDeviceUrl.URL_getPersonInfoByCard)
	public RespMachMessage getPersonInfoByCard(Long companyId, String card){
		return RespUtilMach.success(personnelInfoService.getPerByCard(companyId,card));
	}


	@PostMapping(value = SrvpAccessDeviceUrl.URL_getPersonInfoByPId)
	public RespMachMessage getPersonInfoByPId(Long companyId, Long pId){
		PerInfoDto perInfoDto = personnelInfoService.selectPerInfo(companyId, pId);
		if(perInfoDto!=null){
			return RespUtilMach.success(perInfoDto);
		}
		return RespUtilMach.error(MachEnum.NOT_USER);
	}


}
